﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.Unity;
using SISLOG.BusinessLogic;

namespace SISLOG.Web
{
    public partial class frmCRUDMaterial : BasePage<frmCRUDMaterial>//System.Web.UI.Page
    {
        [Dependency]
        public IMaterialBL MaterialBL { get; set; }

        [Dependency]
        public IProveedorBL ProveedorBL { get; set; }

        string fecha = DateTime.Now.ToShortDateString().ToString();

        protected void Page_Load(object sender, EventArgs e)
        {
            //fechaIngresoTextBox.text = fecha; 
            LabelTitulo.Text = "Editar Material";
            object obj = Request.QueryString["acc"];

            if (obj != null)
            {
                if (obj.ToString() == "nuevo")
                {
                    FormView1.ChangeMode(FormViewMode.Insert);
                    LabelTitulo.Text = "Registrar Material";
                                       
                }
            }
        }

        protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
        {
            Response.Redirect("frmMaterial.aspx");
        }

        protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            Response.Redirect("frmMaterial.aspx");
        }

        protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = MaterialBL;
        }

        protected void ObjectDataSource1_ObjectCreating1(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = ProveedorBL;
        }
    }
}